#!/usr/bin/env python
# encoding: utf-8


"""
@file: dianzai_kexingyu.py
@time: 2017/5/17 下午2:29
"""
# 点落在可行域
from mathsolver.functions.base import *
from mathsolver.functions.budengshi import common_opers as co


# 点落在可行域 求参数的取值范围
# style1 Input paramer1:不等式组, paramer2: 点 output 参数的不等式组
class DianLuoZaiKeXingYu(BaseFunction):
    def solver(self, *args):
        self.label.add('含参数的点落在可行域范围内，求参数范围')
        arg1, arg2 = args
        ineqs = co.simp_ineqs(arg1).sympify()
        point_x, point_y = arg2.sympify()
        subs = (('x', point_x), ('y', point_y))
        ineqs2 = map(lambda _: [_[0].subs(subs), _[1], _[2].subs(subs)], ineqs)
        self.steps.append(['由题意可知:', BaseIneqs(ineqs2).printing()])
        self.output.append(BaseIneqs(ineqs2))
        return self


if __name__ == '__main__':
    pass
    # _solve = DianLuoZaiKeXingYu().solver(BaseIneqs([['x', '>=', '1'], ['y', '>=', '2'], ['x+y', '<=', '4']]),
    #                                      BasePoint(('2*a + b', '3*a - b')))
    # for s1, s2 in _solve.steps:
    #     print s1, s2
    # output1 = _solve.output[0]
    # from mathsolver.functions.budengshi.xianxingguihua.xianxingguihua import XianXingGuiHua
    #
    # _solve = XianXingGuiHua().solver(output1, BasePoly('(b+2)/(a - 1)'), '取值范围')
    # for s1, s2 in _solve.steps:
    #     print s1, s2
